package sugarbind_input

class AgentController {

    def scaffold = true
	
	def ddllectinsupports = {}
	def ddlagents = {}
	
	
	def findLectin_Supports = { 
		println("params : " +params)
		
		def agent
		def lectinSupports
		
		try
		{
			agent = Agent.get(params.agent.id)
		}
		catch(Exception ex)
		{
			println(ex.getMessage())
		}
	
		if(agent != null)
		{
			lectinSupports = agent.lectin_Support
		}
		else
		{
			lectinSupports = Lectin_Support.listLectin_Supports()
		}
		render(template: 'ddlLectinSupports', model:  [lectinSupports : lectinSupports])
			
	  }
	
	
	def findAgents = {
		println("findAgents params : " +params)
			
		def agent_Type
		def agents
		
		try
		{
			agent_Type = Agent_Type.get(params.agent_Type)
			println("findAgents agent_Type : "+agent_Type)
		}
		catch(Exception ex)
		{
			println(ex.getMessage())
		}

		if(agent_Type != null)
		{
			agents = agent_Type.agents
//			render(template: 'ddlArticles', model:  [articles : article_Type.articles])
		}
		else
		{
			agents = Agent.listAgents()
		}
		println(agents)
		render(template: 'ddlAgents', model:  [agents : agents])
	  }
}
